gtkenums.h \
gtkeventbox.h \
gtkexpander.h \
- gtkextendedlayout.h \
gtkfilechooser.h \
gtkfilechooserbutton.h \
gtkfilechooserdialog.h \
gtkshow.h \
gtksettings.h \
gtksizegroup.h \
+ gtksizerequest.h \
gtksocket.h \
gtkspinbutton.h \
gtkspinner.h \
gtkentrycompletion.c \
gtkeventbox.c \
gtkexpander.c \
- gtkextendedlayout.c \
gtkfilechooser.c \
gtkfilechooserbutton.c \
gtkfilechooserdefault.c \
gtkseparatortoolitem.c \
gtksettings.c \
gtksizegroup.c \
+ gtksizerequest.c \
gtkshow.c \
gtksocket.c \
gtkspinbutton.c \
#include <gtk/gtkenums.h>
#include <gtk/gtkeventbox.h>
#include <gtk/gtkexpander.h>
-#include <gtk/gtkextendedlayout.h>
#include <gtk/gtkfixed.h>
#include <gtk/gtkfilechooser.h>
#include <gtk/gtkfilechooserbutton.h>
#include <gtk/gtksettings.h>
#include <gtk/gtkshow.h>
#include <gtk/gtksizegroup.h>
+#include <gtk/gtksizerequest.h>
#include <gtk/gtksocket.h>
#include <gtk/gtkspinbutton.h>
#include <gtk/gtkspinner.h>
#endif
#endif
-#if IN_HEADER(__GTK_EXTENDED_LAYOUT_H__)
-#if IN_FILE(__GTK_EXTENDED_LAYOUT_C__)
-gtk_extended_layout_get_type G_GNUC_CONST
-gtk_extended_layout_get_desired_height
-gtk_extended_layout_get_desired_size
-gtk_extended_layout_get_desired_width
-gtk_extended_layout_get_height_for_width
-gtk_extended_layout_get_width_for_height
-gtk_extended_layout_is_height_for_width
-#endif
-#endif
-
#if IN_HEADER(__GTK_FILE_CHOOSER_H__)
#if IN_FILE(__GTK_FILE_CHOOSER_C__)
gtk_file_chooser_add_filter
#endif
#endif
+#if IN_HEADER(__GTK_SIZE_REQUEST_H__)
+#if IN_FILE(__GTK_SIZE_REQUEST_C__)
+gtk_size_request_get_height
+gtk_size_request_get_height_for_width
+gtk_size_request_get_request_mode
+gtk_size_request_get_size
+gtk_size_request_get_type G_GNUC_CONST
+gtk_size_request_get_width
+gtk_size_request_get_width_for_height
+#endif
+#endif
+
#if IN_HEADER(__GTK_SHOW_H__)
#if IN_FILE(__GTK_SHOW_C__)
gtk_show_uri
#include "config.h"
#include "gtkalignment.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
GValue *value,
GParamSpec *pspec);
-static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_alignment_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_alignment_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_alignment_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_alignment_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_alignment_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_alignment_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_alignment_size_request_init))
static void
gtk_alignment_class_init (GtkAlignmentClass *class)
if (bin->child && gtk_widget_get_visible (bin->child))
{
- GtkExtendedLayout *layout = GTK_EXTENDED_LAYOUT (bin->child);
+ GtkSizeRequest *child = GTK_SIZE_REQUEST (bin->child);
gint child_nat_width;
gint child_nat_height;
gint child_width, child_height;
width = MAX (1, allocation->width - padding_horizontal - 2 * border_width);
height = MAX (1, allocation->height - padding_vertical - 2 * border_width);
- if (gtk_extended_layout_is_height_for_width (layout))
+ if (gtk_size_request_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
- gtk_extended_layout_get_desired_width (layout, NULL, &child_nat_width);
+ gtk_size_request_get_width (child, NULL, &child_nat_width);
child_width = MIN (width, child_nat_width);
- gtk_extended_layout_get_height_for_width (layout, child_width, NULL, &child_nat_height);
+ gtk_size_request_get_height_for_width (child, child_width, NULL, &child_nat_height);
child_height = MIN (height, child_nat_height);
}
else
{
- gtk_extended_layout_get_desired_height (layout, NULL, &child_nat_height);
+ gtk_size_request_get_height (child, NULL, &child_nat_height);
child_height = MIN (height, child_nat_height);
- gtk_extended_layout_get_width_for_height (layout, child_height, NULL, &child_nat_width);
+ gtk_size_request_get_width_for_height (child, child_height, NULL, &child_nat_width);
child_width = MIN (width, child_nat_width);
}
static void
-gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_alignment_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_alignment_get_desired_width;
- iface->get_desired_height = gtk_alignment_get_desired_height;
+ iface->get_width = gtk_alignment_get_width;
+ iface->get_height = gtk_alignment_get_height;
}
static void
-gtk_alignment_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_alignment_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWidget *child;
GtkAlignmentPrivate *priv;
gint minimum, natural;
- priv = GTK_ALIGNMENT_GET_PRIVATE (layout);
+ priv = GTK_ALIGNMENT_GET_PRIVATE (widget);
- natural = minimum = GTK_CONTAINER (layout)->border_width * 2;
+ natural = minimum = GTK_CONTAINER (widget)->border_width * 2;
- if ((child = gtk_bin_get_child (GTK_BIN (layout))) && gtk_widget_get_visible (child))
+ if ((child = gtk_bin_get_child (GTK_BIN (widget))) && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
minimum += (priv->padding_left + priv->padding_right);
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child),
- &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
+ &child_min, &child_nat);
}
else
{
minimum += (priv->padding_top + priv->padding_bottom);
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child),
- &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
+ &child_min, &child_nat);
}
natural = minimum;
}
static void
-gtk_alignment_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_alignment_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_alignment_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_alignment_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_alignment_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_alignment_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
/**
#include "config.h"
#include "gtkbin.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkalias.h"
static GType gtk_bin_child_type (GtkContainer *container);
-static void gtk_bin_extended_layout_init (GtkExtendedLayoutIface *iface);
-static gboolean gtk_bin_is_height_for_width (GtkExtendedLayout *layout);
-static void gtk_bin_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_bin_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+static void gtk_bin_size_request_init (GtkSizeRequestIface *iface);
+static GtkSizeRequestMode gtk_bin_get_request_mode (GtkSizeRequest *widget);
+static void gtk_bin_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_bin_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
-static GtkExtendedLayoutIface *parent_extended_layout_iface;
+static GtkSizeRequestIface *parent_size_request_iface;
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_bin_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_bin_size_request_init))
static void
gtk_bin_class_init (GtkBinClass *class)
/* GtkBin widgets define the padding and borders independantly so
- * we cannot provide a generic get_desired_size() for the same reason
+ * we cannot provide a generic get_size() for the same reason
* we never implemented size_request() here.
*
* But for cases where the GtkBin class's padding is constant and
* cases by using the delta of the base size requsts.
*/
static void
-gtk_bin_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_bin_size_request_init (GtkSizeRequestIface *iface)
{
- parent_extended_layout_iface = g_type_interface_peek_parent (iface);
+ parent_size_request_iface = g_type_interface_peek_parent (iface);
- iface->is_height_for_width = gtk_bin_is_height_for_width;
+ iface->get_request_mode = gtk_bin_get_request_mode;
iface->get_width_for_height = gtk_bin_get_width_for_height;
iface->get_height_for_width = gtk_bin_get_height_for_width;
}
-static gboolean
-gtk_bin_is_height_for_width (GtkExtendedLayout *layout)
+static GtkSizeRequestMode
+gtk_bin_get_request_mode (GtkSizeRequest *widget)
{
- GtkBin *bin = GTK_BIN (layout);
+ GtkBin *bin = GTK_BIN (widget);
if (bin->child)
- return gtk_extended_layout_is_height_for_width (GTK_EXTENDED_LAYOUT (bin->child));
+ return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (bin->child));
- return TRUE;
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
static void
{
gint hmin, vmin, child_hmin, child_vmin;
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin), &hmin, NULL);
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin), &vmin, NULL);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (bin), &hmin, NULL);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (bin), &vmin, NULL);
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child), &child_hmin, NULL);
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child), &child_vmin, NULL);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child), &child_hmin, NULL);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child), &child_vmin, NULL);
*delta_h = hmin - child_hmin;
*delta_v = vmin - child_vmin;
}
static void
-gtk_bin_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_bin_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- GtkBin *bin = GTK_BIN (layout);
+ GtkBin *bin = GTK_BIN (widget);
gint hdelta, vdelta, child_min, child_nat;
if (bin->child)
{
get_child_padding_delta (bin, &hdelta, &vdelta);
- gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (bin->child),
+ gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (bin->child),
height - vdelta,
&child_min, &child_nat);
*natural_width = child_nat + hdelta;
}
else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
}
static void
-gtk_bin_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_bin_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
- GtkBin *bin = GTK_BIN (layout);
+ GtkBin *bin = GTK_BIN (widget);
gint hdelta, vdelta, child_min, child_nat;
if (bin->child)
{
get_child_padding_delta (bin, &hdelta, &vdelta);
- gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (bin->child),
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
width - hdelta,
&child_min, &child_nat);
*natural_height = child_nat + vdelta;
}
else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
}
#include "gtkbox.h"
#include "gtkorientable.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
static GType gtk_box_child_type (GtkContainer *container);
-static void gtk_box_extended_layout_init (GtkExtendedLayoutIface *iface);
-static gboolean gtk_box_is_height_for_width (GtkExtendedLayout *layout);
-static void gtk_box_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_box_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_box_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_box_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-
-static GtkExtendedLayoutIface *parent_extended_layout_iface;
+static void gtk_box_size_request_init (GtkSizeRequestIface *iface);
+static GtkSizeRequestMode gtk_box_get_request_mode (GtkSizeRequest *widget);
+static void gtk_box_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_box_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_box_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_box_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+
+static GtkSizeRequestIface *parent_size_request_iface;
G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
NULL)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_box_extended_layout_init));
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_box_size_request_init));
static void
gtk_box_class_init (GtkBoxClass *class)
if (gtk_widget_get_visible (child->widget))
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
allocation->height,
&sizes[i].minimum_size,
&sizes[i].natural_size);
else
- gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
allocation->width,
&sizes[i].minimum_size,
&sizes[i].natural_size);
static void
-gtk_box_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_box_size_request_init (GtkSizeRequestIface *iface)
{
- parent_extended_layout_iface = g_type_interface_peek_parent (iface);
+ parent_size_request_iface = g_type_interface_peek_parent (iface);
- iface->is_height_for_width = gtk_box_is_height_for_width;
- iface->get_desired_width = gtk_box_get_desired_width;
- iface->get_desired_height = gtk_box_get_desired_height;
+ iface->get_request_mode = gtk_box_get_request_mode;
+ iface->get_width = gtk_box_get_width;
+ iface->get_height = gtk_box_get_height;
iface->get_height_for_width = gtk_box_get_height_for_width;
iface->get_width_for_height = gtk_box_get_width_for_height;
}
-static gboolean
-gtk_box_is_height_for_width (GtkExtendedLayout *layout)
+static GtkSizeRequestMode
+gtk_box_get_request_mode (GtkSizeRequest *widget)
{
- GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
+ GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
- return (private->orientation == GTK_ORIENTATION_VERTICAL);
+ return (private->orientation == GTK_ORIENTATION_VERTICAL) ?
+ GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
}
static void
-gtk_box_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkBox *box;
GtkBoxPrivate *private;
gint border_width;
gint minimum, natural;
- box = GTK_BOX (layout);
+ box = GTK_BOX (widget);
private = GTK_BOX_GET_PRIVATE (box);
border_width = GTK_CONTAINER (box)->border_width;
gint child_minimum, child_natural;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child->widget),
- &child_minimum, &child_natural);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
+ &child_minimum, &child_natural);
else
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child->widget),
- &child_minimum, &child_natural);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
+ &child_minimum, &child_natural);
if (private->orientation == orientation)
{
}
static void
-gtk_box_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_box_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_box_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_box_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_box_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
if (gtk_widget_get_visible (child->widget))
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child->widget),
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
else
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child->widget),
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
/* Assert the api is working properly */
if (sizes[i].minimum_size < 0)
/* Assign the child's position. */
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
child_size, &child_minimum, &child_natural);
else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */
- gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
child_size, &child_minimum, &child_natural);
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
avail_size, &child_size, &child_natural);
else
- gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
avail_size, &child_size, &child_natural);
}
static void
-gtk_box_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_box_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- GtkBox *box = GTK_BOX (layout);
- GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
+ GtkBox *box = GTK_BOX (widget);
+ GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
if (private->orientation == GTK_ORIENTATION_VERTICAL)
gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width);
}
static void
-gtk_box_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_box_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
- GtkBox *box = GTK_BOX (layout);
- GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
+ GtkBox *box = GTK_BOX (widget);
+ GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_box_compute_size_for_opposing_orientation (box, width, minimum_height, natural_height);
#include "gtkstock.h"
#include "gtkiconfactory.h"
#include "gtkactivatable.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
static void gtk_button_set_use_action_appearance (GtkButton *button,
gboolean use_appearance);
-static void gtk_button_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_button_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_button_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_button_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_button_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_button_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
static guint button_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
gtk_button_activatable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_button_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_button_size_request_init))
static void
gtk_button_class_init (GtkButtonClass *klass)
static void
-gtk_button_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_button_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_button_get_desired_width;
- iface->get_desired_height = gtk_button_get_desired_height;
+ iface->get_width = gtk_button_get_width;
+ iface->get_height = gtk_button_get_height;
}
static void
-gtk_button_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_button_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkButton *button = GTK_BUTTON (layout);
+ GtkButton *button = GTK_BUTTON (widget);
GtkWidget *child;
GtkBorder default_border;
GtkBorder inner_border;
gint minimum, natural;
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
- gtk_widget_style_get (GTK_WIDGET (layout),
+ gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- minimum = ((GTK_CONTAINER (layout)->border_width +
- GTK_WIDGET (layout)->style->xthickness) * 2 +
+ minimum = ((GTK_CONTAINER (widget)->border_width +
+ GTK_WIDGET (widget)->style->xthickness) * 2 +
inner_border.left + inner_border.right);
- if (gtk_widget_get_can_default (GTK_WIDGET (layout)))
+ if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
minimum += default_border.left + default_border.right;
}
else
{
- minimum = ((GTK_CONTAINER (layout)->border_width +
- GTK_WIDGET (layout)->style->ythickness) * 2 +
+ minimum = ((GTK_CONTAINER (widget)->border_width +
+ GTK_WIDGET (widget)->style->ythickness) * 2 +
inner_border.top + inner_border.bottom);
- if (gtk_widget_get_can_default (GTK_WIDGET (layout)))
+ if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
minimum += default_border.top + default_border.bottom;
}
gint child_min, child_nat;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child),
- &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
+ &child_min, &child_nat);
else
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child),
- &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
+ &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
static void
-gtk_button_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_button_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_button_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_button_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_button_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_button_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_button_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_button_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
/**
GTK_DRAG_RESULT_ERROR
} GtkDragResult;
+/**
+ * GtkSizeRequestMode:
+ * @GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH: Prefer height-for-width geometry management
+ * @GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT: Prefer width-for-height geometry management
+ *
+ * Specifies a preference for height-for-width or
+ * width-for-height geometry management.
+ */
+typedef enum
+{
+ GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH = 0,
+ GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT,
+} GtkSizeRequestMode;
+
+
G_END_DECLS
#endif /* __GTK_ENUMS_H__ */
+++ /dev/null
-/* gtkextendedlayout.c
- * Copyright (C) 2007-2010 Openismus GmbH
- *
- * Authors:
- * Mathias Hasselmann <mathias@openismus.com>
- * Tristan Van Berkom <tristan.van.berkom@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-/**
- * SECTION:gtkextendedlayout
- * @Short_Description: Height-for-width geometry management
- * @Title: GtkExtendedLayout
- *
- * The extended layout is GTK+'s height-for-width (and width-for-height)
- * geometry management system. Height-for-width means that a widget can
- * change how much vertical space it needs, depending on the amount
- * of horizontal space that it is given (and similar for width-for-height).
- * The most common example is a label that reflows to fill up the available
- * width, wraps to fewer lines, and therefore needs less height.
- *
- * GTK+'s traditional two-pass <link linkend="size-allocation">size-allocation</link>
- * algorithm does not allow this flexibility. #GtkWidget provides a default
- * implementation of the #GtkExtendedLayout interface for existing widgets,
- * which always requests the same height, regardless of the available width.
- *
- * <refsect2>
- * <title>Implementing GtkExtendedLayout</title>
- * <para>
- * Some important things to keep in mind when implementing
- * or using the extended layout.
- *
- * The Extended Layout system will query a logical hierarchy in
- * only one orientation at a time. When widgets are initially queried
- * for their minimum sizes it is generally done in a dual pass
- * in the direction chosen by the toplevel.
- *
- * For instance when queried in the normal height-for-width mode:
- * First the default minimum and natural width for each widget
- * in the interface will computed and collectively returned to
- * the toplevel by way of gtk_extended_layout_get_desired_width().
- * Next, the toplevel will use the minimum width to query for the
- * minimum height contextual to that width using
- * gtk_extended_layout_get_height_for_width(), which will also be a
- * highly recursive operation. This minimum-for-minimum size can be
- * used to set the minimum size constraint on the toplevel.
- *
- * When allocating, each container can use the minimum and natural
- * sizes reported by their children to allocate natural sizes and
- * expose as much content as possible with the given allocation.
- *
- * That means that the request operation at allocation time will
- * usually fire again in contexts of different allocated sizes than
- * the ones originally queried for. #GtkExtendedLayout caches a
- * small number of results to avoid re-querying for the same
- * allocated size in one allocation cycle.
- *
- * A widget that does not actually do height-for-width
- * or width-for-height size negotiations only has to implement
- * get_desired_width() and get_desired_height().
- *
- * If a widget does move content around to smartly use up the
- * allocated size, then it must support the request properly in
- * both orientations; even if the request only makes sense in
- * one orientation.
- *
- * For instance, a GtkLabel that does height-for-width word wrapping
- * will not expect to have get_desired_height() called because that
- * call is specific to a width-for-height request, in this case the
- * label must return the heights contextual to its minimum possible
- * width. By following this rule any widget that handles height-for-width
- * or width-for-height requests will always be allocated at least
- * enough space to fit its own content.
- * </para>
- * </refsect2>
- */
-
-
-#include <config.h>
-#include "gtkextendedlayout.h"
-#include "gtksizegroup.h"
-#include "gtkprivate.h"
-#include "gtkintl.h"
-#include "gtkalias.h"
-
-/* With extended layout, a widget may be requested
- * its width for 2 or maximum 3 heights in one resize
- */
-#define N_CACHED_SIZES 3
-
-typedef struct
-{
- guint age;
- gint for_size;
- gint minimum_size;
- gint natural_size;
-} DesiredSize;
-
-typedef struct {
- DesiredSize desired_widths[N_CACHED_SIZES];
- DesiredSize desired_heights[N_CACHED_SIZES];
- guint8 cached_width_age;
- guint8 cached_height_age;
-} ExtendedLayoutCache;
-
-static GQuark quark_cache = 0;
-
-
-GType
-gtk_extended_layout_get_type (void)
-{
- static GType extended_layout_type = 0;
-
- if (G_UNLIKELY(!extended_layout_type))
- {
- extended_layout_type =
- g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedLayout"),
- sizeof (GtkExtendedLayoutIface),
- NULL, 0, NULL, 0);
-
- g_type_interface_add_prerequisite (extended_layout_type, GTK_TYPE_WIDGET);
-
- quark_cache = g_quark_from_static_string ("gtk-extended-layout-cache");
- }
-
- return extended_layout_type;
-}
-
-/* looks for a cached size request for this for_size. If not
- * found, returns the oldest entry so it can be overwritten
- *
- * Note that this caching code was directly derived from
- * the Clutter toolkit.
- */
-static gboolean
-get_cached_desired_size (gint for_size,
- DesiredSize *cached_sizes,
- DesiredSize **result)
-{
- guint i;
-
- *result = &cached_sizes[0];
-
- for (i = 0; i < N_CACHED_SIZES; i++)
- {
- DesiredSize *cs;
-
- cs = &cached_sizes[i];
-
- if (cs->age > 0 && cs->for_size == for_size)
- {
- *result = cs;
- return TRUE;
- }
- else if (cs->age < (*result)->age)
- {
- *result = cs;
- }
- }
-
- return FALSE;
-}
-
-static void
-destroy_cache (ExtendedLayoutCache *cache)
-{
- g_slice_free (ExtendedLayoutCache, cache);
-}
-
-static ExtendedLayoutCache *
-get_cache (GtkExtendedLayout *layout,
- gboolean create)
-{
- ExtendedLayoutCache *cache;
-
- cache = g_object_get_qdata (G_OBJECT (layout), quark_cache);
- if (!cache && create)
- {
- cache = g_slice_new0 (ExtendedLayoutCache);
-
- cache->cached_width_age = 1;
- cache->cached_height_age = 1;
-
- g_object_set_qdata_full (G_OBJECT (layout), quark_cache, cache,
- (GDestroyNotify)destroy_cache);
- }
-
- return cache;
-}
-
-
-static void
-do_size_request (GtkWidget *widget)
-{
- if (GTK_WIDGET_REQUEST_NEEDED (widget))
- {
- gtk_widget_ensure_style (widget);
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_REQUEST_NEEDED);
- g_signal_emit_by_name (widget,
- "size-request",
- &widget->requisition);
- }
-}
-
-static void
-compute_size_for_orientation (GtkExtendedLayout *layout,
- GtkSizeGroupMode orientation,
- gint for_size,
- gint *minimum_size,
- gint *natural_size)
-{
- ExtendedLayoutCache *cache;
- DesiredSize *cached_size;
- GtkWidget *widget;
- gboolean found_in_cache = FALSE;
-
- g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
- g_return_if_fail (minimum_size != NULL || natural_size != NULL);
-
- widget = GTK_WIDGET (layout);
- cache = get_cache (layout, TRUE);
-
- if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
- {
- cached_size = &cache->desired_widths[0];
-
- if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (layout))
- found_in_cache = get_cached_desired_size (for_size, cache->desired_widths, &cached_size);
- else
- {
- memset (cache->desired_widths, 0, N_CACHED_SIZES * sizeof (DesiredSize));
- cache->cached_width_age = 1;
- }
- }
- else
- {
- cached_size = &cache->desired_heights[0];
-
- if (!GTK_WIDGET_HEIGHT_REQUEST_NEEDED (layout))
- found_in_cache = get_cached_desired_size (for_size, cache->desired_heights, &cached_size);
- else
- {
- memset (cache->desired_heights, 0, N_CACHED_SIZES * sizeof (DesiredSize));
- cache->cached_height_age = 1;
- }
- }
-
- if (!found_in_cache)
- {
- gint min_size = 0, nat_size = 0;
- gint group_size, requisition_size;
-
- /* Unconditional size request runs but is often unhandled. */
- do_size_request (widget);
-
- if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
- {
- requisition_size = widget->requisition.width;
-
- if (for_size < 0)
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, &min_size, &nat_size);
- else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_width_for_height (layout, for_size, &min_size, &nat_size);
- }
- else
- {
- requisition_size = widget->requisition.height;
-
- if (for_size < 0)
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, &min_size, &nat_size);
- else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_height_for_width (layout, for_size, &min_size, &nat_size);
- }
-
- /* Support for dangling "size-request" signals and forward derived
- * classes that will not default to a ->get_desired_width() that
- * returns the values in the ->requisition cache.
- */
- min_size = MAX (min_size, requisition_size);
- nat_size = MAX (nat_size, requisition_size);
-
- cached_size->minimum_size = min_size;
- cached_size->natural_size = nat_size;
- cached_size->for_size = for_size;
-
- if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
- {
- cached_size->age = cache->cached_width_age;
- cache->cached_width_age++;
-
- GTK_PRIVATE_UNSET_FLAG (layout, GTK_WIDTH_REQUEST_NEEDED);
- }
- else
- {
- cached_size->age = cache->cached_height_age;
- cache->cached_height_age++;
-
- GTK_PRIVATE_UNSET_FLAG (layout, GTK_HEIGHT_REQUEST_NEEDED);
- }
-
- /* Get size groups to compute the base requisition once one
- * of the values have been cached, then go ahead and update
- * the cache with the sizegroup computed value.
- *
- * Note this is also where values from gtk_widget_set_size_request()
- * are considered.
- */
- group_size =
- _gtk_size_group_bump_requisition (GTK_WIDGET (layout),
- orientation, cached_size->minimum_size);
-
- cached_size->minimum_size = MAX (cached_size->minimum_size, group_size);
- cached_size->natural_size = MAX (cached_size->natural_size, group_size);
- }
-
- if (minimum_size)
- *minimum_size = cached_size->minimum_size;
-
- if (natural_size)
- *natural_size = cached_size->natural_size;
-
- g_assert (cached_size->minimum_size <= cached_size->natural_size);
-
- GTK_NOTE (EXTENDED_LAYOUT,
- g_print ("[%p] %s\t%s: %d is minimum %d and natural: %d (hit cache: %s)\n",
- layout, G_OBJECT_TYPE_NAME (layout),
- orientation == GTK_SIZE_GROUP_HORIZONTAL ?
- "width for height" : "height for width" ,
- for_size,
- cached_size->minimum_size,
- cached_size->natural_size,
- found_in_cache ? "yes" : "no"));
-
-}
-
-/**
- * gtk_extended_layout_is_height_for_width:
- * @layout: a #GtkExtendedLayout instance
- *
- * Gets whether the widget prefers a height-for-width layout
- * or a width-for-height layout.
- *
- * <note><para>#GtkBin widgets generally propagate the preference of
- * their child, container widgets need to request something either in
- * context of their children or in context of their allocation
- * capabilities.</para></note>
- *
- * Returns: %TRUE if the widget prefers height-for-width, %FALSE if
- * the widget should be treated with a width-for-height preference.
- *
- * Since: 3.0
- */
-gboolean
-gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout)
-{
- GtkExtendedLayoutIface *iface;
-
- g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (layout), FALSE);
-
- iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
- if (iface->is_height_for_width)
- return iface->is_height_for_width (layout);
-
- /* By default widgets are height-for-width. */
- return TRUE;
-}
-
-/**
- * gtk_extended_layout_get_desired_width:
- * @layout: a #GtkExtendedLayout instance
- * @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
- * @natural_width: (out) (allow-none): location to store the natural width, or %NULL
- *
- * Retrieves a widget's initial minimum and natural width.
- *
- * <note><para>This call is specific to height-for-width
- * requests.</para></note>
- *
- * Since: 3.0
- */
-void
-gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_width,
- gint *natural_width)
-{
- compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
- -1, minimum_width, natural_width);
-}
-
-
-/**
- * gtk_extended_layout_get_desired_height:
- * @layout: a #GtkExtendedLayout instance
- * @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
- * @natural_height: (out) (allow-none): location to store the natural height, or %NULL
- *
- * Retrieves a widget's initial minimum and natural height.
- *
- * <note><para>This call is specific to width-for-height requests.</para></note>
- *
- * Since: 3.0
- */
-void
-gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_height,
- gint *natural_height)
-{
- compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
- -1, minimum_height, natural_height);
-}
-
-
-
-/**
- * gtk_extended_layout_get_width_for_height:
- * @layout: a #GtkExtendedLayout instance
- * @height: the height which is available for allocation
- * @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
- * @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
- *
- * Retrieves a widget's desired width if it would be given
- * the specified @height.
- *
- * Since: 3.0
- */
-void
-gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width)
-{
- compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
- height, minimum_width, natural_width);
-}
-
-/**
- * gtk_extended_layout_get_height_for_width:
- * @layout: a #GtkExtendedLayout instance
- * @width: the width which is available for allocation
- * @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
- * @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
- *
- * Retrieves a widget's desired height if it would be given
- * the specified @width.
- *
- * Since: 3.0
- */
-void
-gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height)
-{
- compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
- width, minimum_height, natural_height);
-}
-
-/**
- * gtk_extended_layout_get_desired_size:
- * @layout: a #GtkExtendedLayout instance
- * @request_natural: Whether to base the contextual request off of the
- * base natural or the base minimum
- * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
- * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
- *
- * Retrieves the minimum and natural size of a widget taking
- * into account the widget's preference for height-for-width management.
- *
- * If request_natural is specified, the non-contextual natural value will
- * be used to make the contextual request; otherwise the minimum will be used.
- *
- * This is used to retrieve a suitable size by container widgets which do
- * not impose any restrictions on the child placement.
- *
- * Since: 3.0
- */
-void
-gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
- gboolean request_natural,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
-{
- gint min_width, nat_width;
- gint min_height, nat_height;
-
- g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
-
- if (gtk_extended_layout_is_height_for_width (layout))
- {
- gtk_extended_layout_get_desired_width (layout, &min_width, &nat_width);
- gtk_extended_layout_get_height_for_width (layout,
- request_natural ? nat_width : min_width,
- &min_height, &nat_height);
- }
- else
- {
- gtk_extended_layout_get_desired_height (layout, &min_height, &nat_height);
- gtk_extended_layout_get_width_for_height (layout,
- request_natural ? nat_height : min_height,
- &min_width, &nat_width);
- }
-
- if (minimum_size)
- {
- minimum_size->width = min_width;
- minimum_size->height = min_height;
- }
-
- if (natural_size)
- {
- natural_size->width = nat_width;
- natural_size->height = nat_height;
- }
-}
-
-
-
-#define __GTK_EXTENDED_LAYOUT_C__
-#include "gtkaliasdef.c"
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2007-2010 Openismus GmbH
- *
- * Authors:
- * Mathias Hasselmann <mathias@openismus.com>
- * Tristan Van Berkom <tristan.van.berkom@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GTK_EXTENDED_LAYOUT_H__
-#define __GTK_EXTENDED_LAYOUT_H__
-
-#include <gtk/gtkwidget.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_EXTENDED_LAYOUT (gtk_extended_layout_get_type ())
-#define GTK_EXTENDED_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXTENDED_LAYOUT, GtkExtendedLayout))
-#define GTK_EXTENDED_LAYOUT_CLASS(klass) ((GtkExtendedLayoutIface*)g_type_interface_peek ((klass), GTK_TYPE_EXTENDED_LAYOUT))
-#define GTK_IS_EXTENDED_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXTENDED_LAYOUT))
-#define GTK_EXTENDED_LAYOUT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_EXTENDED_LAYOUT, GtkExtendedLayoutIface))
-
-typedef struct _GtkExtendedLayout GtkExtendedLayout;
-typedef struct _GtkExtendedLayoutIface GtkExtendedLayoutIface;
-
-struct _GtkExtendedLayoutIface
-{
- GTypeInterface g_iface;
-
- /* virtual table */
- gboolean (* is_height_for_width) (GtkExtendedLayout *layout);
-
- void (* get_desired_width) (GtkExtendedLayout *layout,
- gint *minimum_width,
- gint *natural_width);
- void (* get_desired_height) (GtkExtendedLayout *layout,
- gint *minimum_height,
- gint *natural_height);
- void (* get_width_for_height) (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width);
- void (* get_height_for_width) (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-};
-
-GType gtk_extended_layout_get_type (void) G_GNUC_CONST;
-
-gboolean gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout);
-void gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_width,
- gint *natural_width);
-void gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_height,
- gint *natural_height);
-void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-void gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-
-void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
- gboolean request_natural,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size);
-
-
-G_END_DECLS
-
-#endif /* __GTK_EXTENDED_LAYOUT_H__ */
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkbuildable.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkalias.h"
#define LABEL_PAD 1
GObject *child,
const gchar *type);
-static void gtk_frame_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_frame_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_frame_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_frame_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_frame_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_frame_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_frame_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_frame_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_frame_size_request_init))
static void
gtk_frame_class_init (GtkFrameClass *class)
}
static void
-gtk_frame_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_size (GtkSizeRequest *request,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkWidget *widget = GTK_WIDGET (layout);
+ GtkWidget *widget = GTK_WIDGET (request);
GtkFrame *frame = GTK_FRAME (widget);
GtkBin *bin = GTK_BIN (widget);
gint child_min, child_nat;
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (frame->label_widget),
- &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (frame->label_widget),
+ &child_min, &child_nat);
minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
}
else
{
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (frame->label_widget),
- &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (frame->label_widget),
+ &child_min, &child_nat);
minimum = MAX (0, child_min - widget->style->ythickness);
natural = MAX (0, child_nat - widget->style->ythickness);
}
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child),
- &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
+ &child_min, &child_nat);
minimum = MAX (minimum, child_min);
natural = MAX (natural, child_nat);
}
else
{
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child),
- &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
+ &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
}
static void
-gtk_frame_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_frame_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_frame_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_frame_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_frame_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_frame_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_frame_get_desired_width;
- iface->get_desired_height = gtk_frame_get_desired_height;
+ iface->get_width = gtk_frame_get_width;
+ iface->get_height = gtk_frame_get_height;
}
#define __GTK_FRAME_C__
#include "gtkimage.h"
#include "gtkshow.h"
#include "gtktooltip.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkalias.h"
static void emit_activate_link (GtkLabel *label,
GtkLabelLink *link);
-static void gtk_label_extended_layout_init (GtkExtendedLayoutIface *iface);
-static gboolean gtk_label_is_height_for_width (GtkExtendedLayout *layout);
-static void gtk_label_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_label_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_label_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_label_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+static void gtk_label_size_request_init (GtkSizeRequestIface *iface);
+static GtkSizeRequestMode gtk_label_get_request_mode (GtkSizeRequest *widget);
+static void gtk_label_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_label_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_label_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_label_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
static GQuark quark_angle = 0;
G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_label_buildable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_label_extended_layout_init));
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_label_size_request_init));
static void
add_move_binding (GtkBindingSet *binding_set,
}
static void
-gtk_label_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_label_size_request_init (GtkSizeRequestIface *iface)
{
- iface->is_height_for_width = gtk_label_is_height_for_width;
- iface->get_desired_width = gtk_label_get_desired_width;
- iface->get_desired_height = gtk_label_get_desired_height;
+ iface->get_request_mode = gtk_label_get_request_mode;
+ iface->get_width = gtk_label_get_width;
+ iface->get_height = gtk_label_get_height;
iface->get_width_for_height = gtk_label_get_width_for_height;
iface->get_height_for_width = gtk_label_get_height_for_width;
}
-static gboolean
-gtk_label_is_height_for_width (GtkExtendedLayout *layout)
+static GtkSizeRequestMode
+gtk_label_get_request_mode (GtkSizeRequest *layout)
{
GtkLabel *label = GTK_LABEL (layout);
gdouble angle = gtk_label_get_angle (label);
if (angle == 90 || angle == 270)
- return FALSE;
+ return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
- return TRUE;
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
static void
}
static void
-gtk_label_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkLabel *label = GTK_LABEL (layout);
+ GtkLabel *label = GTK_LABEL (widget);
PangoRectangle required_rect;
PangoRectangle natural_rect;
gdouble angle;
static void
-gtk_label_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_label_get_desired_size (layout,
- GTK_ORIENTATION_HORIZONTAL,
- minimum_size, natural_size);
+ gtk_label_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_label_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_label_get_desired_size (layout,
- GTK_ORIENTATION_VERTICAL,
- minimum_size, natural_size);
+ gtk_label_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_label_get_width_for_height (GtkExtendedLayout *layout,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_label_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- GtkLabel *label = GTK_LABEL (layout);
+ GtkLabel *label = GTK_LABEL (widget);
gdouble angle = gtk_label_get_angle (label);
if (label->wrap && (angle == 90 || angle == 270))
*natural_width += label->misc.xpad * 2;
}
else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
}
static void
-gtk_label_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_label_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
- GtkLabel *label = GTK_LABEL (layout);
+ GtkLabel *label = GTK_LABEL (widget);
gdouble angle = gtk_label_get_angle (label);
if (label->wrap && (angle == 0 || angle == 180 || angle == 360))
*natural_height += label->misc.ypad * 2;
}
else
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
}
static void
#include <math.h>
#include <gdk/gdkkeysyms.h>
#include "gtkbindings.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkmarshalers.h"
#include "gtkscrolledwindow.h"
#include "gtkwindow.h"
static void gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window);
-static void gtk_scrolled_window_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_scrolled_window_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_scrolled_window_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_scrolled_window_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-static void gtk_scrolled_window_get_width_for_height (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+static void gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_scrolled_window_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_scrolled_window_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_scrolled_window_get_height_for_width (GtkSizeRequest *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_scrolled_window_get_width_for_height (GtkSizeRequest *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
static guint signals[LAST_SIGNAL] = {0};
G_DEFINE_TYPE_WITH_CODE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_scrolled_window_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_scrolled_window_size_request_init))
static void
static void
-gtk_scrolled_window_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_scrolled_window_get_desired_width;
- iface->get_desired_height = gtk_scrolled_window_get_desired_height;
+ iface->get_width = gtk_scrolled_window_get_width;
+ iface->get_height = gtk_scrolled_window_get_height;
iface->get_height_for_width = gtk_scrolled_window_get_height_for_width;
iface->get_width_for_height = gtk_scrolled_window_get_width_for_height;
}
static void
-gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkScrolledWindow *scrolled_window;
GtkBin *bin;
GtkRequisition minimum_req, natural_req;
gint min_child_size, nat_child_size;
- scrolled_window = GTK_SCROLLED_WINDOW (layout);
+ scrolled_window = GTK_SCROLLED_WINDOW (widget);
bin = GTK_BIN (scrolled_window);
scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child),
- &min_child_size,
- &nat_child_size);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
+ &min_child_size,
+ &nat_child_size);
if (scrolled_window->hscrollbar_policy == GTK_POLICY_NEVER)
{
}
else /* GTK_ORIENTATION_VERTICAL */
{
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child),
- &min_child_size,
- &nat_child_size);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
+ &min_child_size,
+ &nat_child_size);
if (scrolled_window->vscrollbar_policy == GTK_POLICY_NEVER)
{
extra_width = scrollbar_spacing + vscrollbar_requisition.width;
}
- minimum_req.width += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_width);
- minimum_req.height += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_height);
- natural_req.width += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_width);
- natural_req.height += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_height);
+ minimum_req.width += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_width);
+ minimum_req.height += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_height);
+ natural_req.width += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_width);
+ natural_req.height += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_height);
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
- minimum_req.width += 2 * GTK_WIDGET (layout)->style->xthickness;
- minimum_req.height += 2 * GTK_WIDGET (layout)->style->ythickness;
- natural_req.width += 2 * GTK_WIDGET (layout)->style->xthickness;
- natural_req.height += 2 * GTK_WIDGET (layout)->style->ythickness;
+ minimum_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
+ minimum_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
+ natural_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
+ natural_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
}
static void
-gtk_scrolled_window_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_scrolled_window_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_scrolled_window_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_scrolled_window_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_scrolled_window_get_height_for_width (GtkExtendedLayout *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_scrolled_window_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
- g_return_if_fail (GTK_IS_WIDGET (layout));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
}
static void
-gtk_scrolled_window_get_width_for_height (GtkExtendedLayout *layout,
+gtk_scrolled_window_get_width_for_height (GtkSizeRequest *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
- g_return_if_fail (GTK_IS_WIDGET (layout));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
+ GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
}
#define __GTK_SCROLLED_WINDOW_C__
#include "gtkprivate.h"
#include "gtksizegroup.h"
#include "gtkbuildable.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkalias.h"
enum {
/* XXX Possibly we should be using natural values and not minimums here. */
gint width;
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (widget), &width, NULL);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (widget), &width, NULL);
return width;
}
/* XXX Possibly we should be using natural values and not minimums here. */
gint height;
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (widget), &height, NULL);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (widget), &height, NULL);
return height;
}
* value in the dimension @mode.
*
* This function is used to update sizegroup minimum size information
- * in multiple passes from the new #GtkExtendedLayout manager.
+ * in multiple passes from the new #GtkSizeRequest manager.
*/
gint
_gtk_size_group_bump_requisition (GtkWidget *widget,
--- /dev/null
+/* gtksizerequest.c
+ * Copyright (C) 2007-2010 Openismus GmbH
+ *
+ * Authors:
+ * Mathias Hasselmann <mathias@openismus.com>
+ * Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+/**
+ * SECTION:gtksizerequest
+ * @Short_Description: Height-for-width geometry management
+ * @Title: GtkSizeRequest
+ *
+ * The GtkSizeGroup interface is GTK+'s height-for-width (and width-for-height)
+ * geometry management system. Height-for-width means that a widget can
+ * change how much vertical space it needs, depending on the amount
+ * of horizontal space that it is given (and similar for width-for-height).
+ * The most common example is a label that reflows to fill up the available
+ * width, wraps to fewer lines, and therefore needs less height.
+ *
+ * GTK+'s traditional two-pass <link linkend="size-allocation">size-allocation</link>
+ * algorithm does not allow this flexibility. #GtkWidget provides a default
+ * implementation of the #GtkSizeGroup interface for existing widgets,
+ * which always requests the same height, regardless of the available width.
+ *
+ * <refsect2>
+ * <title>Implementing GtkSizeRequest</title>
+ * <para>
+ * Some important things to keep in mind when implementing
+ * the GtkSizeRequest interface and when using it in container
+ * implementations.
+ *
+ * The geometry management system will query a logical hierarchy in
+ * only one orientation at a time. When widgets are initially queried
+ * for their minimum sizes it is generally done in a dual pass
+ * in the direction chosen by the toplevel.
+ *
+ * For instance when queried in the normal height-for-width mode:
+ * First the default minimum and natural width for each widget
+ * in the interface will computed and collectively returned to
+ * the toplevel by way of gtk_size_request_get_desired_width().
+ * Next, the toplevel will use the minimum width to query for the
+ * minimum height contextual to that width using
+ * gtk_size_request_get_height_for_width(), which will also be a
+ * highly recursive operation. This minimum-for-minimum size can be
+ * used to set the minimum size constraint on the toplevel.
+ *
+ * When allocating, each container can use the minimum and natural
+ * sizes reported by their children to allocate natural sizes and
+ * expose as much content as possible with the given allocation.
+ *
+ * That means that the request operation at allocation time will
+ * usually fire again in contexts of different allocated sizes than
+ * the ones originally queried for. #GtkSizeRequest caches a
+ * small number of results to avoid re-querying for the same
+ * allocated size in one allocation cycle.
+ *
+ * A widget that does not actually do height-for-width
+ * or width-for-height size negotiations only has to implement
+ * get_width() and get_height().
+ *
+ * If a widget does move content around to smartly use up the
+ * allocated size, then it must support the request properly in
+ * both orientations; even if the request only makes sense in
+ * one orientation.
+ *
+ * For instance, a GtkLabel that does height-for-width word wrapping
+ * will not expect to have get_height() called because that
+ * call is specific to a width-for-height request, in this case the
+ * label must return the heights contextual to its minimum possible
+ * width. By following this rule any widget that handles height-for-width
+ * or width-for-height requests will always be allocated at least
+ * enough space to fit its own content.
+ * </para>
+ * </refsect2>
+ */
+
+
+#include <config.h>
+#include "gtksizerequest.h"
+#include "gtksizegroup.h"
+#include "gtkprivate.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
+
+/* With GtkSizeRequest, a widget may be requested
+ * its width for 2 or maximum 3 heights in one resize
+ */
+#define N_CACHED_SIZES 3
+
+typedef struct
+{
+ guint age;
+ gint for_size;
+ gint minimum_size;
+ gint natural_size;
+} SizeRequest;
+
+typedef struct {
+ SizeRequest widths[N_CACHED_SIZES];
+ SizeRequest heights[N_CACHED_SIZES];
+ guint8 cached_width_age;
+ guint8 cached_height_age;
+} SizeRequestCache;
+
+static GQuark quark_cache = 0;
+
+
+GType
+gtk_size_request_get_type (void)
+{
+ static GType size_request_type = 0;
+
+ if (G_UNLIKELY(!size_request_type))
+ {
+ size_request_type =
+ g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkSizeRequest"),
+ sizeof (GtkSizeRequestIface),
+ NULL, 0, NULL, 0);
+
+ g_type_interface_add_prerequisite (size_request_type, GTK_TYPE_WIDGET);
+
+ quark_cache = g_quark_from_static_string ("gtk-size-request-cache");
+ }
+
+ return size_request_type;
+}
+
+/* looks for a cached size request for this for_size. If not
+ * found, returns the oldest entry so it can be overwritten
+ *
+ * Note that this caching code was directly derived from
+ * the Clutter toolkit.
+ */
+static gboolean
+get_cached_size (gint for_size,
+ SizeRequest *cached_sizes,
+ SizeRequest **result)
+{
+ guint i;
+
+ *result = &cached_sizes[0];
+
+ for (i = 0; i < N_CACHED_SIZES; i++)
+ {
+ SizeRequest *cs;
+
+ cs = &cached_sizes[i];
+
+ if (cs->age > 0 && cs->for_size == for_size)
+ {
+ *result = cs;
+ return TRUE;
+ }
+ else if (cs->age < (*result)->age)
+ {
+ *result = cs;
+ }
+ }
+
+ return FALSE;
+}
+
+static void
+destroy_cache (SizeRequestCache *cache)
+{
+ g_slice_free (SizeRequestCache, cache);
+}
+
+static SizeRequestCache *
+get_cache (GtkSizeRequest *widget,
+ gboolean create)
+{
+ SizeRequestCache *cache;
+
+ cache = g_object_get_qdata (G_OBJECT (widget), quark_cache);
+ if (!cache && create)
+ {
+ cache = g_slice_new0 (SizeRequestCache);
+
+ cache->cached_width_age = 1;
+ cache->cached_height_age = 1;
+
+ g_object_set_qdata_full (G_OBJECT (widget), quark_cache, cache,
+ (GDestroyNotify)destroy_cache);
+ }
+
+ return cache;
+}
+
+
+static void
+do_size_request (GtkWidget *widget)
+{
+ if (GTK_WIDGET_REQUEST_NEEDED (widget))
+ {
+ gtk_widget_ensure_style (widget);
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_REQUEST_NEEDED);
+ g_signal_emit_by_name (widget,
+ "size-request",
+ &widget->requisition);
+ }
+}
+
+static void
+compute_size_for_orientation (GtkSizeRequest *request,
+ GtkSizeGroupMode orientation,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ SizeRequestCache *cache;
+ SizeRequest *cached_size;
+ GtkWidget *widget;
+ gboolean found_in_cache = FALSE;
+
+ g_return_if_fail (GTK_IS_SIZE_REQUEST (request));
+ g_return_if_fail (minimum_size != NULL || natural_size != NULL);
+
+ widget = GTK_WIDGET (request);
+ cache = get_cache (request, TRUE);
+
+ if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+ {
+ cached_size = &cache->widths[0];
+
+ if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (request))
+ found_in_cache = get_cached_size (for_size, cache->widths, &cached_size);
+ else
+ {
+ memset (cache->widths, 0, N_CACHED_SIZES * sizeof (SizeRequest));
+ cache->cached_width_age = 1;
+ }
+ }
+ else
+ {
+ cached_size = &cache->heights[0];
+
+ if (!GTK_WIDGET_HEIGHT_REQUEST_NEEDED (request))
+ found_in_cache = get_cached_size (for_size, cache->heights, &cached_size);
+ else
+ {
+ memset (cache->heights, 0, N_CACHED_SIZES * sizeof (SizeRequest));
+ cache->cached_height_age = 1;
+ }
+ }
+
+ if (!found_in_cache)
+ {
+ gint min_size = 0, nat_size = 0;
+ gint group_size, requisition_size;
+
+ /* Unconditional size request runs but is often unhandled. */
+ do_size_request (widget);
+
+ if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+ {
+ requisition_size = widget->requisition.width;
+
+ if (for_size < 0)
+ GTK_SIZE_REQUEST_GET_IFACE (request)->get_width (request, &min_size, &nat_size);
+ else
+ GTK_SIZE_REQUEST_GET_IFACE (request)->get_width_for_height (request, for_size,
+ &min_size, &nat_size);
+ }
+ else
+ {
+ requisition_size = widget->requisition.height;
+
+ if (for_size < 0)
+ GTK_SIZE_REQUEST_GET_IFACE (request)->get_height (request, &min_size, &nat_size);
+ else
+ GTK_SIZE_REQUEST_GET_IFACE (request)->get_height_for_width (request, for_size,
+ &min_size, &nat_size);
+ }
+
+ /* Support for dangling "size-request" signals and forward derived
+ * classes that will not default to a ->get_width() that
+ * returns the values in the ->requisition cache.
+ */
+ min_size = MAX (min_size, requisition_size);
+ nat_size = MAX (nat_size, requisition_size);
+
+ cached_size->minimum_size = min_size;
+ cached_size->natural_size = nat_size;
+ cached_size->for_size = for_size;
+
+ if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+ {
+ cached_size->age = cache->cached_width_age;
+ cache->cached_width_age++;
+
+ GTK_PRIVATE_UNSET_FLAG (request, GTK_WIDTH_REQUEST_NEEDED);
+ }
+ else
+ {
+ cached_size->age = cache->cached_height_age;
+ cache->cached_height_age++;
+
+ GTK_PRIVATE_UNSET_FLAG (request, GTK_HEIGHT_REQUEST_NEEDED);
+ }
+
+ /* Get size groups to compute the base requisition once one
+ * of the values have been cached, then go ahead and update
+ * the cache with the sizegroup computed value.
+ *
+ * Note this is also where values from gtk_widget_set_size_request()
+ * are considered.
+ */
+ group_size =
+ _gtk_size_group_bump_requisition (GTK_WIDGET (request),
+ orientation, cached_size->minimum_size);
+
+ cached_size->minimum_size = MAX (cached_size->minimum_size, group_size);
+ cached_size->natural_size = MAX (cached_size->natural_size, group_size);
+ }
+
+ if (minimum_size)
+ *minimum_size = cached_size->minimum_size;
+
+ if (natural_size)
+ *natural_size = cached_size->natural_size;
+
+ g_assert (cached_size->minimum_size <= cached_size->natural_size);
+
+ GTK_NOTE (SIZE_REQUEST,
+ g_print ("[%p] %s\t%s: %d is minimum %d and natural: %d (hit cache: %s)\n",
+ request, G_OBJECT_TYPE_NAME (request),
+ orientation == GTK_SIZE_GROUP_HORIZONTAL ?
+ "width for height" : "height for width" ,
+ for_size,
+ cached_size->minimum_size,
+ cached_size->natural_size,
+ found_in_cache ? "yes" : "no"));
+
+}
+
+/**
+ * gtk_size_request_is_height_for_width:
+ * @widget: a #GtkSizeRequest instance
+ *
+ * Gets whether the widget prefers a height-for-width layout
+ * or a width-for-height layout.
+ *
+ * <note><para>#GtkBin widgets generally propagate the preference of
+ * their child, container widgets need to request something either in
+ * context of their children or in context of their allocation
+ * capabilities.</para></note>
+ *
+ * Returns: %TRUE if the widget prefers height-for-width, %FALSE if
+ * the widget should be treated with a width-for-height preference.
+ *
+ * Since: 3.0
+ */
+GtkSizeRequestMode
+gtk_size_request_get_request_mode (GtkSizeRequest *widget)
+{
+ GtkSizeRequestIface *iface;
+
+ g_return_val_if_fail (GTK_IS_SIZE_REQUEST (widget), GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH);
+
+ iface = GTK_SIZE_REQUEST_GET_IFACE (widget);
+ if (iface->get_request_mode)
+ return iface->get_request_mode (widget);
+
+ /* By default widgets are height-for-width. */
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+}
+
+/**
+ * gtk_size_request_get_width:
+ * @widget: a #GtkSizeRequest instance
+ * @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
+ * @natural_width: (out) (allow-none): location to store the natural width, or %NULL
+ *
+ * Retrieves a widget's initial minimum and natural width.
+ *
+ * <note><para>This call is specific to height-for-width
+ * requests.</para></note>
+ *
+ * Since: 3.0
+ */
+void
+gtk_size_request_get_width (GtkSizeRequest *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
+ -1, minimum_width, natural_width);
+}
+
+
+/**
+ * gtk_size_request_get_height:
+ * @widget: a #GtkSizeRequest instance
+ * @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
+ * @natural_height: (out) (allow-none): location to store the natural height, or %NULL
+ *
+ * Retrieves a widget's initial minimum and natural height.
+ *
+ * <note><para>This call is specific to width-for-height requests.</para></note>
+ *
+ * Since: 3.0
+ */
+void
+gtk_size_request_get_height (GtkSizeRequest *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
+ -1, minimum_height, natural_height);
+}
+
+
+
+/**
+ * gtk_size_request_get_width_for_height:
+ * @widget: a #GtkSizeRequest instance
+ * @height: the height which is available for allocation
+ * @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
+ * @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
+ *
+ * Retrieves a widget's desired width if it would be given
+ * the specified @height.
+ *
+ * Since: 3.0
+ */
+void
+gtk_size_request_get_width_for_height (GtkSizeRequest *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
+ height, minimum_width, natural_width);
+}
+
+/**
+ * gtk_size_request_get_height_for_width:
+ * @widget: a #GtkSizeRequest instance
+ * @width: the width which is available for allocation
+ * @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
+ * @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
+ *
+ * Retrieves a widget's desired height if it would be given
+ * the specified @width.
+ *
+ * Since: 3.0
+ */
+void
+gtk_size_request_get_height_for_width (GtkSizeRequest *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
+ width, minimum_height, natural_height);
+}
+
+/**
+ * gtk_size_request_get_size:
+ * @widget: a #GtkSizeRequest instance
+ * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
+ * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
+ *
+ * Retrieves the minimum and natural size of a widget taking
+ * into account the widget's preference for height-for-width management.
+ *
+ * This is used to retrieve a suitable size by container widgets which do
+ * not impose any restrictions on the child placement.
+ *
+ * Since: 3.0
+ */
+void
+gtk_size_request_get_size (GtkSizeRequest *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
+{
+ gint min_width, nat_width;
+ gint min_height, nat_height;
+
+ g_return_if_fail (GTK_IS_SIZE_REQUEST (widget));
+
+ if (gtk_size_request_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ {
+ gtk_size_request_get_width (widget, &min_width, &nat_width);
+
+ if (minimum_size)
+ {
+ minimum_size->width = min_width;
+ gtk_size_request_get_height_for_width (widget, min_width,
+ &minimum_size->height, NULL);
+ }
+
+ if (natural_size)
+ {
+ natural_size->width = nat_width;
+ gtk_size_request_get_height_for_width (widget, nat_width,
+ NULL, &natural_size->height);
+ }
+ }
+ else
+ {
+ gtk_size_request_get_height (widget, &min_height, &nat_height);
+
+ if (minimum_size)
+ {
+ minimum_size->height = min_height;
+ gtk_size_request_get_width_for_height (widget, min_height,
+ &minimum_size->width, NULL);
+ }
+
+ if (natural_size)
+ {
+ natural_size->height = nat_height;
+ gtk_size_request_get_width_for_height (widget, nat_height,
+ NULL, &natural_size->width);
+ }
+ }
+}
+
+
+
+#define __GTK_SIZE_REQUEST_C__
+#include "gtkaliasdef.c"
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2007-2010 Openismus GmbH
+ *
+ * Authors:
+ * Mathias Hasselmann <mathias@openismus.com>
+ * Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_SIZE_REQUEST_H__
+#define __GTK_SIZE_REQUEST_H__
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SIZE_REQUEST (gtk_size_request_get_type ())
+#define GTK_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequest))
+#define GTK_SIZE_REQUEST_CLASS(klass) ((GtkSizeRequestIface*)g_type_interface_peek ((klass), GTK_TYPE_SIZE_REQUEST))
+#define GTK_IS_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SIZE_REQUEST))
+#define GTK_SIZE_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequestIface))
+
+typedef struct _GtkSizeRequest GtkSizeRequest;
+typedef struct _GtkSizeRequestIface GtkSizeRequestIface;
+
+
+struct _GtkSizeRequestIface
+{
+ GTypeInterface g_iface;
+
+ /* virtual table */
+ GtkSizeRequestMode (* get_request_mode) (GtkSizeRequest *layout);
+
+ void (* get_height) (GtkSizeRequest *layout,
+ gint *minimum_height,
+ gint *natural_height);
+ void (* get_width_for_height) (GtkSizeRequest *layout,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+ void (* get_width) (GtkSizeRequest *layout,
+ gint *minimum_width,
+ gint *natural_width);
+ void (* get_height_for_width) (GtkSizeRequest *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+};
+
+GType gtk_size_request_get_type (void) G_GNUC_CONST;
+
+GtkSizeRequestMode gtk_size_request_get_request_mode (GtkSizeRequest *layout);
+void gtk_size_request_get_width (GtkSizeRequest *layout,
+ gint *minimum_width,
+ gint *natural_width);
+void gtk_size_request_get_height_for_width (GtkSizeRequest *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+void gtk_size_request_get_height (GtkSizeRequest *layout,
+ gint *minimum_height,
+ gint *natural_height);
+void gtk_size_request_get_width_for_height (GtkSizeRequest *layout,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+void gtk_size_request_get_size (GtkSizeRequest *layout,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size);
+
+G_END_DECLS
+
+#endif /* __GTK_SIZE_REQUEST_H__ */
#include "config.h"
#include "gtkviewport.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
static void gtk_viewport_style_set (GtkWidget *widget,
GtkStyle *previous_style);
-static void gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_viewport_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_viewport_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_viewport_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_viewport_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_viewport_size_request_init))
static void
gtk_viewport_class_init (GtkViewportClass *class)
{
gint natural_height;
- gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (bin->child),
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
view_allocation.width,
NULL,
&natural_height);
static void
-gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_viewport_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_viewport_get_desired_width;
- iface->get_desired_height = gtk_viewport_get_desired_height;
+ iface->get_width = gtk_viewport_get_width;
+ iface->get_height = gtk_viewport_get_height;
}
static void
-gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_size (GtkSizeRequest *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWidget *child;
gint child_min, child_nat;
gint minimum, natural;
- child = gtk_bin_get_child (GTK_BIN (layout));
+ child = gtk_bin_get_child (GTK_BIN (widget));
/* XXX This should probably be (border_width * 2); but GTK+ has
* been doing this with a single border for a while now...
*/
- minimum = GTK_CONTAINER (layout)->border_width;
+ minimum = GTK_CONTAINER (widget)->border_width;
- if (GTK_VIEWPORT (layout)->shadow_type != GTK_SHADOW_NONE)
+ if (GTK_VIEWPORT (widget)->shadow_type != GTK_SHADOW_NONE)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- minimum += 2 * GTK_WIDGET (layout)->style->xthickness;
+ minimum += 2 * GTK_WIDGET (widget)->style->xthickness;
else
- minimum += 2 * GTK_WIDGET (layout)->style->ythickness;
+ minimum += 2 * GTK_WIDGET (widget)->style->ythickness;
}
natural = minimum;
if (child && gtk_widget_get_visible (child))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
else
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
static void
-gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_viewport_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_viewport_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
#define __GTK_VIEWPORT_C__
#include "gtkinvisible.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkalias.h"
/**
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder);
-static void gtk_widget_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_widget_real_get_desired_width (GtkExtendedLayout *layout,
+static void gtk_widget_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_widget_real_get_width (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_widget_real_get_desired_height (GtkExtendedLayout *layout,
+static void gtk_widget_real_get_height (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
const GInterfaceInfo layout_info =
{
- (GInterfaceInitFunc) gtk_widget_extended_layout_init,
+ (GInterfaceInitFunc) gtk_widget_size_request_init,
(GInterfaceFinalizeFunc) NULL,
NULL /* interface data */
};
&accessibility_info) ;
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
&buildable_info) ;
- g_type_add_interface_static (widget_type, GTK_TYPE_EXTENDED_LAYOUT,
+ g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
&layout_info) ;
}
* Also remember that the size request is not necessarily the size
* a widget will actually be allocated.
*
- * Deprecated: 3.0: Use gtk_extended_layout_get_desired_size() instead.
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
**/
void
gtk_widget_size_request (GtkWidget *widget,
"to widget->requisition. gtk_widget_set_usize() may not work properly.");
#endif /* G_ENABLE_DEBUG */
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
+ gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
}
/**
* gtk_widget_size_request().
*
*
- * Deprecated: 3.0: Use gtk_extended_layout_get_desired_size() instead.
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
**/
void
gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition)
{
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
+ gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
}
static gboolean
}
/*
- * GtkExtendedLayout implementation
+ * GtkSizeRequest implementation
*/
static void
-gtk_widget_real_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
/* Set the initial values so that unimplemented classes will fall back
* on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
*/
if (minimum_size)
- *minimum_size = GTK_WIDGET (layout)->requisition.width;
+ *minimum_size = GTK_WIDGET (widget)->requisition.width;
if (natural_size)
- *natural_size = GTK_WIDGET (layout)->requisition.width;
+ *natural_size = GTK_WIDGET (widget)->requisition.width;
}
static void
-gtk_widget_real_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
/* Set the initial values so that unimplemented classes will fall back
* on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
*/
if (minimum_size)
- *minimum_size = GTK_WIDGET (layout)->requisition.height;
+ *minimum_size = GTK_WIDGET (widget)->requisition.height;
if (natural_size)
- *natural_size = GTK_WIDGET (layout)->requisition.height;
+ *natural_size = GTK_WIDGET (widget)->requisition.height;
}
static void
-gtk_widget_real_get_height_for_width (GtkExtendedLayout *layout,
+gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
gint width,
gint *minimum_height,
gint *natural_height)
{
- gtk_extended_layout_get_desired_height (layout, minimum_height, natural_height);
+ gtk_size_request_get_height (layout, minimum_height, natural_height);
}
static void
-gtk_widget_real_get_width_for_height (GtkExtendedLayout *layout,
+gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
gint height,
gint *minimum_width,
gint *natural_width)
{
- gtk_extended_layout_get_desired_width (layout, minimum_width, natural_width);
+ gtk_size_request_get_width (layout, minimum_width, natural_width);
}
static void
-gtk_widget_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_widget_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_widget_real_get_desired_width;
- iface->get_desired_height = gtk_widget_real_get_desired_height;
+ iface->get_width = gtk_widget_real_get_width;
+ iface->get_height = gtk_widget_real_get_height;
iface->get_width_for_height = gtk_widget_real_get_width_for_height;
iface->get_height_for_width = gtk_widget_real_get_height_for_width;
}
#include "gtkmarshalers.h"
#include "gtkplug.h"
#include "gtkbuildable.h"
-#include "gtkextendedlayout.h"
+#include "gtksizerequest.h"
#include "gtkalias.h"
#ifdef GDK_WINDOWING_X11
gpointer user_data);
-static void gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface);
-static void gtk_window_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_window_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_window_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_window_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_window_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_window_buildable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
- gtk_window_extended_layout_init))
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
+ gtk_window_size_request_init))
static void
add_tab_bindings (GtkBindingSet *binding_set,
static void
-gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_window_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_width = gtk_window_get_desired_width;
- iface->get_desired_height = gtk_window_get_desired_height;
+ iface->get_width = gtk_window_get_width;
+ iface->get_height = gtk_window_get_height;
}
static void
-gtk_window_get_desired_width (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_window_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWindow *window;
GtkWidget *child;
- window = GTK_WINDOW (layout);
+ window = GTK_WINDOW (widget);
child = gtk_bin_get_child (GTK_BIN (window));
*minimum_size = GTK_CONTAINER (window)->border_width * 2;
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
*minimum_size += child_min;
*natural_size += child_nat;
}
static void
-gtk_window_get_desired_height (GtkExtendedLayout *layout,
- gint *minimum_size,
- gint *natural_size)
+gtk_window_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWindow *window;
GtkWidget *child;
- window = GTK_WINDOW (layout);
+ window = GTK_WINDOW (widget);
child = gtk_bin_get_child (GTK_BIN (window));
*minimum_size = GTK_CONTAINER (window)->border_width * 2;
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
*minimum_size += child_min;
*natural_size += child_nat;
simple \
flicker \
print-editor \
- extendedlayoutexample \
testaccel \
testassistant \
testbbox \
testfilechooserbutton \
testframe \
testgtk \
+ testheightforwidth \
testiconview \
testiconview-keynav \
testicontheme \
flicker_DEPENDENCIES = $(TEST_DEPS)
simple_DEPENDENCIES = $(TEST_DEPS)
print_editor_DEPENDENCIES = $(TEST_DEPS)
-extendedlayoutexample_DEPENDENCIES = $(TEST_DEPS)
+testheightforwidth_DEPENDENCIES = $(TEST_DEPS)
testicontheme_DEPENDENCIES = $(TEST_DEPS)
testiconview_DEPENDENCIES = $(TEST_DEPS)
testaccel_DEPENDENCIES = $(TEST_DEPS)
flicker_LDADD = $(LDADDS)
simple_LDADD = $(LDADDS)
print_editor_LDADD = $(LDADDS)
-extendedlayoutexample_LDADD = $(LDADDS)
testaccel_LDADD = $(LDADDS)
testapplication_LDADD = $(LDADDS)
testassistant_LDADD = $(LDADDS)
testfilechooser_LDADD = $(LDADDS)
testfilechooserbutton_LDADD = $(LDADDS)
testgtk_LDADD = $(LDADDS)
+testheightforwidth_LDADD = $(LDADDS)
testicontheme_LDADD = $(LDADDS)
testiconview_LDADD = $(LDADDS)
testiconview_keynav_LDADD = $(LDADDS)
gtk_widget_translate_coordinates (label, widget, 0, 0, &x, &y);
layout = gtk_widget_create_pango_layout (widget, "");
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (label), FALSE,
- &minimum_size, &natural_size);
+ gtk_size_request_get_size (GTK_SIZE_REQUEST (label),
+ &minimum_size, &natural_size);
pango_layout_set_markup (layout,
"<span color='#c33'>\342\227\217 requisition</span>\n"
--- /dev/null
+/* extendedlayoutexample.c
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * Author:
+ * Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+typedef struct {
+ const gchar *name;
+ const gchar *tooltip;
+ const gchar *interface;
+ GtkWidget *window;
+} TestInterface;
+
+
+/* These strings were generated with:
+ *
+ * IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
+ */
+TestInterface interfaces[] = {
+ {
+ "Ellipsizing Labels",
+ "Demonstrates how labels will request a natural size in a horizontal space",
+ "<interface>"
+ " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <!-- interface-naming-policy project-wide -->"
+ " <object class=\"GtkWindow\" id=\"window\">"
+ " <property name=\"default_width\">450</property>"
+ " <property name=\"default_height\">50</property>"
+ " <child>"
+ " <object class=\"GtkHBox\" id=\"hbox5\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label9\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
+ " <property name=\"ellipsize\">end</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label10\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">but some</property>"
+ " <property name=\"ellipsize\">end</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label11\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">do not at all</property>"
+ " <attributes>"
+ " <attribute name=\"style\" value=\"normal\"/>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">2</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>",
+ NULL
+ },
+
+ {
+ "Wrapping Label",
+ "Demonstrates how a wrapping label can require a height contextual to its allocated width",
+ "<interface>"
+ " <requires lib=\"gtk+\" version=\"2.18\"/>"
+ " <!-- interface-naming-policy project-wide -->"
+ " <object class=\"GtkWindow\" id=\"window\">"
+ " <property name=\"border_width\">12</property>"
+ " <property name=\"default_width\">300</property>"
+ " <child>"
+ " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <child>"
+ " <object class=\"GtkVBox\" id=\"vbox2\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label3\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">A short static label.</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkFrame\" id=\"frame1\">"
+ " <property name=\"label\">Long label</property>"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This is a really long label for the purpose of testing line wrapping is working correctly in conjunction with height-for-width support in GTK+</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"max_width_chars\">30</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
+ " </attributes>"
+ " </object>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkButton\" id=\"button2\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <property name=\"receives_default\">True</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label2\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"max_width_chars\">25</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
+ " </attributes>"
+ " </object>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">2</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">False</property>"
+ " <property name=\"shrink\">False</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label4\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This static label\n"
+ "can shrink.</property>"
+ " <property name=\"justify\">center</property>"
+ " <attributes>"
+ " <attribute name=\"style\" value=\"normal\"/>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">True</property>"
+ " <property name=\"shrink\">True</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>",
+ NULL
+ },
+
+ {
+ "Horizontal Box",
+ "Demonstrates how a horizontal box can calculate the collective height for an allocated width",
+ "<interface>"
+ " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <!-- interface-naming-policy project-wide -->"
+ " <object class=\"GtkWindow\" id=\"window\">"
+ " <property name=\"default_height\">200</property>"
+ " <property name=\"default_width\">600</property>"
+ " <child>"
+ " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <child>"
+ " <object class=\"GtkVBox\" id=\"vbox1\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkButton\" id=\"button1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <property name=\"receives_default\">True</property>"
+ " <property name=\"use_action_appearance\">False</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label2\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">10</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
+ " </attributes>"
+ " </object>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Lets try setting up some long text to wrap up in this hbox and see if the height-for-width is gonna work !</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">30</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkButton\" id=\"button2\">"
+ " <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <property name=\"receives_default\">True</property>"
+ " <property name=\"use_action_appearance\">False</property>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">False</property>"
+ " <property name=\"shrink\">False</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label4\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This label is\n"
+ "set to shrink inside\n"
+ "the paned window.</property>"
+ " <property name=\"justify\">center</property>"
+ " <attributes>"
+ " <attribute name=\"style\" value=\"normal\"/>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">True</property>"
+ " <property name=\"shrink\">True</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>",
+ NULL
+ },
+
+ {
+ "Vertical Labels",
+ "Demonstrates how a horizontal box will consider width-for-height when allocating children "
+ "even if the toplevel window is requested as height-for-width.",
+ "<interface>"
+ " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <!-- interface-naming-policy project-wide -->"
+ " <object class=\"GtkWindow\" id=\"window\">"
+ " <property name=\"default_width\">400</property>"
+ " <property name=\"default_height\">300</property>"
+ " <child>"
+ " <object class=\"GtkVPaned\" id=\"vpaned1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <child>"
+ " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
+ " <property name=\"justify\">center</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">10</property>"
+ " <property name=\"angle\">90</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkFrame\" id=\"frame1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label_xalign\">0</property>"
+ " <property name=\"shadow_type\">out</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label5\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Neither of the panes are\n"
+ "set to shrink.</property>"
+ " <property name=\"justify\">center</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " </child>"
+ " <child type=\"label_item\">"
+ " <placeholder/>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">False</property>"
+ " <property name=\"shrink\">False</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkHBox\" id=\"hbox2\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkFrame\" id=\"frame2\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label_xalign\">0</property>"
+ " <property name=\"shadow_type\">out</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label4\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">The interface is allocated as height\n"
+ "for width, but the horizontal boxes\n"
+ "allocate in width for height mode.</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#000097970808\"/>"
+ " </attributes>"
+ " </object>"
+ " </child>"
+ " <child type=\"label_item\">"
+ " <placeholder/>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label3\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
+ " <property name=\"justify\">center</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">10</property>"
+ " <property name=\"angle\">270</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">False</property>"
+ " <property name=\"shrink\">False</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>",
+ NULL
+ },
+
+ {
+ "Label Parameters",
+ "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
+ "to effect minimum and natural widths in wrapping labels.",
+ "<interface>"
+ " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <!-- interface-naming-policy project-wide -->"
+ " <object class=\"GtkWindow\" id=\"window\">"
+ " <property name=\"default_width\">900</property>"
+ " <child>"
+ " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"can_focus\">True</property>"
+ " <child>"
+ " <object class=\"GtkVBox\" id=\"vbox1\">"
+ " <property name=\"visible\">True</property>"
+ " <child>"
+ " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"spacing\">6</property>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label1\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">10</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">False</property>"
+ " <property name=\"fill\">False</property>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label2\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
+ " <property name=\"wrap\">True</property>"
+ " <property name=\"width_chars\">10</property>"
+ " <property name=\"max_width_chars\">20</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"expand\">True</property>"
+ " <property name=\"fill\">True</property>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label3\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
+ " <property name=\"wrap\">True</property>"
+ " <attributes>"
+ " <attribute name=\"weight\" value=\"bold\"/>"
+ " <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">2</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">0</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label4\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
+ "properties can be used to specify the minimum requested wrap width\n"
+ "and the maximum natural wrap width respectively.</property>"
+ " <property name=\"ellipsize\">end</property>"
+ " <property name=\"width_chars\">30</property>"
+ " <attributes>"
+ " <attribute name=\"style\" value=\"normal\"/>"
+ " <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"position\">1</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">False</property>"
+ " <property name=\"shrink\">False</property>"
+ " </packing>"
+ " </child>"
+ " <child>"
+ " <object class=\"GtkLabel\" id=\"label5\">"
+ " <property name=\"visible\">True</property>"
+ " <property name=\"label\" translatable=\"yes\">Some static\n"
+ "text that shrinks.\n"
+ "\n"
+ "You will need to stretch\n"
+ "this window quite wide\n"
+ "to see the effects.</property>"
+ " <property name=\"justify\">center</property>"
+ " <attributes>"
+ " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
+ " </attributes>"
+ " </object>"
+ " <packing>"
+ " <property name=\"resize\">True</property>"
+ " <property name=\"shrink\">True</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " </object>"
+ "</interface>",
+ NULL
+ },
+
+};
+
+
+static void
+test_clicked (GtkWidget *button,
+ TestInterface *interface)
+{
+ if (!interface->window)
+ {
+ GtkBuilder *builder = gtk_builder_new ();
+
+ gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
+ interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
+
+ g_signal_connect (interface->window, "delete_event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+ }
+
+ gtk_widget_show (interface->window);
+}
+
+
+static GtkWidget *
+create_window (void)
+{
+ GtkWidget *window, *vbox, *button;
+ gint i;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ vbox = gtk_vbox_new (FALSE, 6);
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
+ {
+ button = gtk_button_new_with_label (interfaces[i].name);
+
+ gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);
+
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (test_clicked), &interfaces[i]);
+
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+ }
+
+ return window;
+}
+
+
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+
+ gtk_init (&argc, &argv);
+
+ window = create_window ();
+
+ g_signal_connect (window, "delete-event",
+ G_CALLBACK (gtk_main_quit), window);
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}